var uart = require('uart');

function ArrayToString(fileData) {
  var dataString = "";
  for (var i = 0; i < fileData.length; i++) {
    dataString += String.fromCharCode(fileData[i]);
  }
  return dataString;
}

var msgbuf = [97, 98, 99, 100];

// user uart
var serial1 = uart.open({
  id: 'UART1'
});

// user uart
var serial2 = uart.open({
  id: 'UART2'
});

// user uart send data
serial1.write(msgbuf);
serial2.write(msgbuf);

// user uart data receive 
serial1.on('data', function (data) {
  console.log('uart1 receive data is ' + ArrayToString(data));
  serial1.write(data);
});

serial2.on('data', function (data) {
  console.log('uart2 receive data is ' + ArrayToString(data));
  serial2.write(data);
});